#include <boost/asio.hpp>
#include <iostream>

using boost::asio::ip::tcp;

int main()
{
    boost::asio::io_context ctx;

    tcp::resolver resolver(ctx);
    auto endpoints = resolver.resolve("", "5002");
    tcp::socket socket(ctx);
    boost::asio::connect(socket, endpoints);
    while (true)
    {
        std::array<char, 1024> buf;
        boost::system::error_code error;
        buf[0] = 0;
        buf[1] = 0;
        buf[2] = 0;
        buf[3] = 2;
        buf[4] = 'f';
        buf[5] = 'f';
        socket.send(boost::asio::buffer(buf, 6));

        size_t len = socket.read_some(boost::asio::buffer(buf), error);
        if (error == boost::asio::error::eof)
            return 0;
        else if (error)
            return -1;
        std::cout.write(buf.data(), len);
    }
    return 0;
}